export {
    Menu,
};

/**
 * 菜单
 */
class Menu {
    id: number;
    pid: number;
    pids = '';
    name: string;
    url: string;
    icon: string;
    rank: number;
    actions: string;
    routerUrls: string;

    isChecked = false;      // 选中状态，false，没有选中，ture：选中

    routerUrlArray: string[] = [];

    children: Menu[] = [];

    constructor() { }

    init(param: any[], routerUrls: string[]): Menu {
        this.id = param[0];
        this.pid = param[1];
        this.url = param[2];
        this.icon = param[3];
        this.name = param[4];
        this.routerUrlArray = routerUrls;
        return this;
    }

    contains(url: string): boolean {
        if (url === this.url) {
            return true;
        }
        if (this.children && this.children.length > 0) {
            let flag = this.contains(url);
            if (flag) {
                return true;
            }
        }
        return false;
    }


    setDataValue(data: any) {
        this.id = data.id;
        this.pid = data.pid;
        this.url = data.url;
        this.icon = data.icon;
        this.name = data.name;
        this.rank = data.rank;
        this.actions = data.actions;
        this.routerUrls = data.routerUrls;
        this.routerUrlArray = data.routerUrls ? this.routerUrls.split(',') : [];
    }



}
